<template>
  <div>
    <!-- 商品名 -->
    <van-nav-bar :title="title" left-arrow>
      <template #left>
        <van-icon name="arrow-left" color="black" size="18" @click="back"/>
      </template>
      <template #right>
        <van-icon name="ellipsis" color="black" size="22" />
      </template>
    </van-nav-bar>
    <!-- Tab -->
    <van-tabs id="tabs" v-model="active" @click="changeGood(active)">
      <van-tab id="tabb" v-for="(item) in tabs" :title="item.ColTitle" :key="item.ColId"
      >
        <DetailListBody/>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
import { DetailData } from '../api/xly-api'
import DetailListBody from '../components/DetailListBody.vue'
import 'vant/lib/index.css'
export default {
  data() {
    return {
      tabs: [],
      title:"白茶",
      active:0
    }
  },
  created () {
    let goodsId = this.$route.query.goodsId
    DetailData(goodsId).then(res =>{
    //   console.log(res.data.data.list);
      this.title = res.data.data.list[0].ColTitle
      this.tabs = res.data.data.list[0].list[0].list
    });
  },
  components: {
    DetailListBody,
  },
  methods: {
      back() {
          this.$router.push('/goodsList')
      },
      changeGood(index){
        //   console.log(index);
        //   console.log(this.tabs[index].ColId);
          this.$router.push({path:'/detailList',query: {goodsId: this.tabs[index].ColId}})
      }
  },
};
window.onscroll = function () {
  let height = document.documentElement.scrollTop
    //  console.log(document.documentElement.scrollTop);
     let tab = document.querySelectorAll('.van-tabs__wrap')[0]
     let tab1 = document.querySelectorAll('.van-tabs__content')[0]
     if(height>46){
       tab.style.position = 'fixed'
       tab1.style.paddingTop = '46px'
     }else{
       tab.style.position = 'relative'
       tab.style.width = '100%'
       tab1.style.paddingTop = '0'

     }
}
</script>

<style lang="less" scoped>
/deep/.van-tab--active{
    color: #ee0a24;
    // font-weight: bold;
}
/deep/.van-tabs__line{
    display: none;
}
/deep/.van-tabs__wrap{
  top: 0px;
  z-index: 10;
}
/deep/.Search-search{
    display: flex;
    background-color: #323232;
}
/deep/.van-tabs__nav{
  padding-left: 0;
}
.Detail{
    background-color: #f4f4f4;
}
.Search-search{
    display:flex;
    align-items: center;
    background: rgb(244, 244, 244);
    text-align: center;
}
.van-search{
    width: 60%;
}
.Search-i{
    width: 10%;
    color: #747474;
}
.van-search__content{
    background: #fff;
}
.Search-swiper{
    width: 100%;
    position: relative;
}
.van-swipe-item img{
    width: 100%;
}
.swiper-num{
    position: absolute;
    bottom: 5.4rem;
    right: 0.4rem;
    color: #fff;
    font-size: .46667rem;
    line-height: 1.3rem;
    padding: 0 0.46667rem;
    border-radius: 10em;
    display: -webkit-box;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    align-items: center;
    background-color: rgba(0,0,0,.5);
    z-index: 8;
}
.main-activity{
    display:flex;
}
.activity1{
    width:75%;
    background-color: #ee0a24;
    padding: 0.4rem 0 0.4rem 0.4rem;
    color: #fff;
}
.activity2{
    width:25%;
    background-color: #fdff4f;
    padding: 0.4rem 0 0.4rem 0.4rem;
    position: relative;
}
.swi-img{
    vertical-align: top;
}
.activity-price__wrap{
    font-size: 1.25rem;
}
.activity-price__description{
    font-size: 0.8rem;
    padding-left: 0.2rem;
}
.colon {
    display: inline-block;
    margin: 0 4px;
    color: #ee0a24;
  }
  .block {
    display: inline-block;
    width: 1.2rem;
    color: #fff;
    font-size: 12px;
    text-align: center;
    background-color: #ee0a24;
    border-radius:0.2rem ;
  }
.activity-countdown__label{
    font-size: 0.8rem;
    color: #ee0a24;
    text-align: center;
}
.van-count-down{
    margin-top: 0.3rem;
    text-align: center;
}
.activity2::after{
    content: "";
    position: absolute;
    top: -0.05rem;
    left: -2.72rem;
    width: 0;
    height: 0;
    border: 0.48rem dashed transparent;
    border-width: 1.78rem 1.78rem 1.78rem 1rem;
    border-right-style: solid;
    border-right-color: #fdff4f;
}
.m-goods__tag {
    margin-right: 0.20667rem;
    display: inline-block;
    color: #fff;
    font-size: .7em;
    font-weight: 400;
    line-height: 1.1rem;
    padding: 0 0.5rem;
    border-radius: 1.2rem;
    vertical-align: 0.5333rem;
    background-color: #ee0a24;
    position: relative;
    top: .44rem;
}
.detail-box1,.detail-box{
    margin: 0.6rem 0.6rem 0;
    border-radius: 0.4rem;
    background-color: #fff;
    overflow: hidden;
    padding: 0.4rem;
}
.detail-box1-ul{
    margin-top: 0.8rem;
    display:flex;
    justify-content: space-between;
}
.detail-box1-ul li{
    font-size: .32rem;
    line-height: .42667rem;
    padding: 0.26667rem;
    color: #747474;
}
.detail-box2 div{
    display: inline-block;
    line-height: 1rem;
    padding: 0.5rem;
}
.d2-sp1{
    font-size: 0.5rem;
    color: #747474;
}
.d2-sp2{
    font-size: 0.5rem;
}
.detail-picture{
    position: relative;
    padding: 0.2rem 0;
    text-align: center;
    line-height: .48rem;
    font-size: 0.8rem;
    color: #747474;
}
.detail-picture span{
    position: relative;
    display: inline-block;
    color: #969799;
    line-height: 0.5rem;
    padding: 1rem;
    background-color: #f4f4f4;
    z-index: 2;
}
.detail-picture::after{
    content: " ";
    position: absolute;
    pointer-events: none;
    box-sizing: border-box;
    top: 0;
    right: 0;
    left: 50%;
    border-top: 1px solid #969799;
    -webkit-transform: scaleY(.5);
    transform: scaleY(.5);
    top: 50%;
    width: 40%;
    -webkit-transform: scaleY(.5) translateX(-50%);
    transform: scaleY(.5) translateX(-50%);
}
.dp-p{
    margin: 0;
    width: 100%;
}
.dp-p img{
    width: 100%;
    vertical-align: middle;
}
.van-col{
    padding: .5rem;
}
.van-col>div{
    background-color: #fff;
    border-radius: .5rem;
    overflow: hidden;
}
.van-col div img{
    width: 100%;
}
.detailgt{
    display: -webkit-box;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: calc(var(--m-goods-title-line-height)*2);
    max-height: calc(var(--m-goods-title-line-height)*2);
    font-size: 0.9rem;
    color: #323232;
    margin-bottom: .2rem;
}
.detailbody{
    padding: .5rem;
}
.detailpric{
    color: #ee0a24;
}
.detailpric span{
    font-size: .5rem;
}
.detailpeo{
    color: #969799;
    font-size: .6rem;
    margin-left: .2rem;
}
.van-goods-action{
    z-index: 10;
}
.ddt{
    display: -webkit-box;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: calc(var(--m-goods-title-line-height)*2);
    max-height: calc(var(--m-goods-title-line-height)*2);
    font-size: .9rem;
}
.detail-box3 .van-col{
    padding: .2rem;
}
.ddt p{
    margin: 0;
}
.decc{
    position: relative;
    right:-9rem;
}
.pop-header{
    text-align: center;
    font-size: 1rem;
}
.pop-p{
    padding: .5rem;
    border-bottom: 1px solid #f4f4f4;
}
.pop-s1{
    font-size: .8rem;
    color: #969799;
    display: inline-block;
    width: 4rem;
}
.pop-s2{
    font-size: .8rem;
    margin-left: 1.5rem;
}
.van-popup .van-button{
    position: fixed;
    bottom: 0;
}
.van-button__content{
    display: flex !important;
    padding: 0 !important;
}
</style>